<?php
namespace app\model;

class TeachingPlan extends BaseModel
{
    protected $name = 'teaching_plans';

    // 自动时间戳
    protected $autoWriteTimestamp = true;

    // 类型转换
    protected $type = [
        'created_at' => 'integer',
        'updated_at' => 'integer',
        'delete_time' => 'integer'
    ];

    /**
     * 关联用户
     */
    public function user()
    {
        return $this->belongsTo(User::class);
    }

    /**
     * 关联笔记
     */
    public function note()
    {
        return $this->belongsTo(Note::class);
    }

    /**
     * 关联教案元素
     */
    public function elements()
    {
        return $this->hasMany(TeachingPlanElement::class, 'plan_id');
    }
} 